package com.heima.user.controller;

import com.heima.model.article.dtos.ArticleInfoDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.UserRelationDto;
import com.heima.user.service.UserRelationService;
import com.heima.utils.common.WmThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.heima.user.interceptor.TokenInterceptor.THREADLOCAL;

@RestController
@RequestMapping("/api/v1/user")
@Slf4j
public class UserController {
    @Autowired
    UserRelationService userRelationService;
    @PostMapping("/user_follow")
    public ResponseResult followWithInterest(@RequestBody UserRelationDto userRelationDto){
        System.out.println("关注接口接收参数"+userRelationDto);
        System.out.println("当前用户"+THREADLOCAL.get());
        return userRelationService.saveUserRelation(userRelationDto);
    }

    /**
     * 查询是否关注
     * @param articleInfoDto
     * @return
     */
    @PostMapping("/RelationSearch")
    ResponseResult RelationSearch(@RequestBody ArticleInfoDto articleInfoDto){
        return userRelationService.RelationSearch(articleInfoDto);
    };
}
